package com.mz.ozy.adapter;

import android.content.Context;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;

import androidx.annotation.NonNull;
import androidx.viewpager.widget.PagerAdapter;

import com.bumptech.glide.Glide;
import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.BaseViewHolder;
import com.mz.ozy.R;
import com.mz.ozy.bean.HomeMerBean;
import com.mz.ozy.bean.ObShopTitleBean;
import com.mz.ozy.utils.glideUtils.GlideUtils;

import java.util.List;

/**
 * @author wansong
 * @description:
 * @date :2020/9/28 16:33
 */
public class ObShopBannerAdapter extends PagerAdapter {

    private Context context;
    private List<ObShopTitleBean.BannerListBean> list;

    public ObShopBannerAdapter(Context context, List<ObShopTitleBean.BannerListBean> data) {
        this.context = context;
        this.list = data;
    }


    @Override
    public int getCount() {
        return list.size();
    }

    @Override
    public boolean isViewFromObject(@NonNull View view, @NonNull Object object) {
        return view == object;
    }

    @NonNull
    @Override
    public Object instantiateItem(@NonNull ViewGroup container, int position) {
        ImageView imageView = new ImageView(context);
        imageView.setScaleType(ImageView.ScaleType.FIT_XY);
        GlideUtils.loadImg(context, imageView, list.get(position).getImgPath(), 4);
        container.addView(imageView);
        return imageView;
    }

    @Override
    public void destroyItem(@NonNull ViewGroup container, int position, @NonNull Object object) {
        container.removeView((View) object);
    }
}
